<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        var tree = {
            value: 'a',
            left: {
                value: 'b',
                left: {
                    value: 'c'
                }
            },
            right: {
                value: 'd',
                left: {
                    value: 'e',
                },
                right: {
                    value: 'f'
                }

            }
        }

        // 前序遍历
        function eachTree(tree) {
            console.log(tree.value);
            if (!tree.left && !tree.right) {
                return;
            }
            if (tree.left) eachTree(tree.left);
            if (tree.right) eachTree(tree.right);
        }
        eachTree(tree);
    </script>
</body>

</html>